package cn.hc.sp03.user.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import sp01.pojo.User;
import sp01.service.UserService;
import web.util.JsonResult;

/**
 * @author 海绵宝宝
 * date 2021/10/29 23:31
 */
@Slf4j
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/{id}")
    public JsonResult<User> getUser(@PathVariable Integer id){
        User user = userService.getUser(id);
        return JsonResult.ok().data(user);
    }
    @GetMapping("/{id}/score")
    public JsonResult<?> addScore(@PathVariable Integer id,Integer score){
        userService.addScore(id,score);
        return JsonResult.ok().msg("增加用户积分成功！");
    }
}
